﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;

namespace ZRT.RHPX.UI.Controllers
{
    public class SysMenuEntity
    {
        public int ID { get; set; }
        public int ParentID { get; set; }
        public string MenuName { get; set; }
        public string MenuDesc { get; set; }
        public string MenuUrl { get; set; }
        public List<SysMenuEntity> children { get; set; }
    }

    public class MenuController : Controller
    {
        //
        // GET: /Menu/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult MenuList()
        {
            //json格式 参考 http://www.java1234.com/easyui.html

            SysMenuEntity Entity1 = new SysMenuEntity
            {
                ID = 1,
                MenuDesc = "描述",
                MenuName = "系统管理",
                MenuUrl = "",
                ParentID = 0,
                children = new List<SysMenuEntity>()
            };
            SysMenuEntity Entity11 = new SysMenuEntity
            {
                ID = 11,
                MenuDesc = "描述",
                MenuName = "用户管理",
                MenuUrl = "",
                ParentID = 1
            };
            SysMenuEntity Entity12 = new SysMenuEntity
            {
                ID = 12,
                MenuDesc = "描述",
                MenuName = "菜单管理",
                MenuUrl = "",
                ParentID = 1
            };

            Entity1.children.Add(Entity11);
            Entity1.children.Add(Entity12);

            SysMenuEntity Entity2 = new SysMenuEntity
            {
                ID = 2,
                MenuDesc = "描述",
                MenuName = "系统管理",
                MenuUrl = "",
                ParentID = 0,
                children = new List<SysMenuEntity>()
            };
            SysMenuEntity Entity22 = new SysMenuEntity
            {
                ID = 22,
                MenuDesc = "描述",
                MenuName = "用户管理",
                MenuUrl = "",
                ParentID = 2,
                children = new List<SysMenuEntity>()
            };
            SysMenuEntity Entity222 = new SysMenuEntity
            {
                ID = 222,
                MenuDesc = "描述",
                MenuName = "用户管理",
                MenuUrl = "",
                ParentID = 22,
                children = new List<SysMenuEntity>()
            };
            Entity22.children.Add(Entity222);
            Entity2.children.Add(Entity22);

            List<SysMenuEntity> list = new List<SysMenuEntity>();
            list.Add(Entity1);
            list.Add(Entity2);

            return Json(list, JsonRequestBehavior.AllowGet);
        }
    }
}
